package org.alex.samples.dao;

import java.util.List;

import org.alex.samples.model.ExamTest;
import org.springframework.stereotype.Repository;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional

public class ExamTestDAOImpl extends BaseHibernateDAO<ExamTest> implements IExamTestDAO {

	
	@Override
	public List<ExamTest> FindAllExamTest() throws Exception{
		String hql = " FROM ExamTest ";
		return queryForList(hql, null);
	}
	
	@Override
	public ExamTest FindExamTestById(int id) throws Exception{
		ExamTest examTest = this.get(id);
		return examTest;
	}
	
	@Override
	public void creatExamTest(ExamTest examTest) throws Exception{
		this.save(examTest);
	}
	
	@Rollback(false)
	@Override
	public void editExamTest(ExamTest examTest) throws Exception{
			this.update(examTest);
	
	}

	@Override
	public void deleteExamTest(int id) throws Exception{
		ExamTest examTest = this.get(id);
		if(examTest != null){
			this.delete(examTest);
		}
		
	}

	@Override
	public List<ExamTest> FindExamTestListBySubjectId(Integer subjectId) {
		String hql = " FROM ExamTest where sub_id = ? ";
		return queryForList(hql, new Object[]{subjectId});
	}
	
}
